package echa

import (
	"context"
	"fmt"
	"fuxi/config"
	"github.com/go-redis/redis/v8"
	"log"
)

var Ctx = context.Background()
var Rdb *redis.Client

func Init() {
	res := config.GetConfigData.Redis
	qwer := fmt.Sprintf("%s:%d", res.Host, res.Port)
	Rdb = redis.NewClient(&redis.Options{
		Addr:     qwer,
		Password: "A555E8D900DF406E47F39665C8CA7D75", // no password set
		DB:       0,                                  // use default DB
	})

	err := Rdb.Set(Ctx, "key", "value", 0).Err()
	if err != nil {
		panic(err)
	}
	log.Println("Redis 连接成功")

}
